package com.huayun.plugin.pointcloud.domain;

import java.math.BigDecimal;

public class Point {
    private double x;
    private double y;
    private double z;
//    public double u;
//    public double v;

    public Point(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public Point(double[] points) {
        this.x = points[0];
        this.y = points[1];
        this.z = points[2];
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getZ() {
        return z;
    }

    public void setZ(double z) {
        this.z = z;
    }

    public double getDistance(Point point) {
        BigDecimal x = new BigDecimal(this.getX()).subtract(new BigDecimal(point.getX()));
        BigDecimal y = new BigDecimal(this.getY()).subtract(new BigDecimal(point.getY()));
        BigDecimal z = new BigDecimal(this.getZ()).subtract(new BigDecimal(point.getZ()));
        BigDecimal root = x.pow(2).add(y.pow(2)).add(z.pow(2));
        return Math.sqrt(root.doubleValue());
    }
}
